import React, { Fragment, useState, useEffect } from 'react';

import { getTimeString } from '../../../utils/toolKit';


export default function Time() {

    const [time, setTime] = useState(getTimeString());

    useEffect(() => {
        const timer = setInterval(() => {
            setTime(getTimeString());
        }, 1000)
        return () => {
            clearInterval(timer);
        }
    }, [])

    return (
        <Fragment>
            <span className="time">{time}</span>
        </Fragment>
    )
}
